name: Preload Magisk
inputs:
  cache-key:
    description: 'Magisk cache-key'
    required: true

runs:
  using: "composite"
  steps:
    - uses: actions/cache@v3
      id: cache-magisk
      with:
        key: ${{ inputs.cache-key }}
        # Make sure any changes to path are also reflected in ci.yml setup
        path: tests/files/magisk

    - if: ${{ ! steps.cache-magisk.outputs.cache-hit }}
      uses: awalsh128/cache-apt-pkgs-action@v1
      with:
        packages: python3-lz4 python3-protobuf

    - if: ${{ ! steps.cache-magisk.outputs.cache-hit }}
      uses: awalsh128/cache-apt-pkgs-action@v1
      with:
        packages: python3-strictyaml

    - name: Downloading Magisk
      if: ${{ ! steps.cache-magisk.outputs.cache-hit }}
      shell: sh
      run: |
        ./tests/tests.py \
          download \
          --magisk \
          --no-devices
